<!DOCTYPE html>
<html>
<head>
    <!--[if lt IE 7]>
    <div class="ie6_error">还在用<strong>漏洞百出的IE6浏览器</strong>么？为了您的网络安全，请升级浏览器 <a target="_blank"
                                                                               href="http://browsehappy.com">立即升级</a>
    </div>
    <![endif]-->

    <meta charset="utf-8">
    <title>个人中心-admin账期-文具1号</title>
    <meta name="description"
          content="文具1号作为上海办公用品供货商公司,专为世界500强企业及SOHO办公族提供网上商城一站式办公耗材批发及采购服务,一站式选购办公日用文具用品,厂家直销,好货又便宜【阳光采购就上文具1号 阳光价格 老板放心 品质保障 员工省力】"/>
    <meta name="keywords" content="办公用品,办公文具,办公文具网站,文具网站,办公用品网,文具采购网,金万年"/>
    <meta name="copyright" content="上海易推信息科技有限公司"/>
    <meta name="renderer" content="webkit">
    <base href="<?php echo base_url(); ?>"/>
    <link rel="shortcut icon" href="favicon.ico"/>
    <link rel="stylesheet" href="public/js/layui/css/layui.css">
    <link rel="stylesheet" type="text/css" href="public/css/base.css"/>
    <link rel="stylesheet" type="text/css" href="public/css/common.css"/>
    <link rel="stylesheet" type="text/css" href="public/css/cost-center.css"/>
    <link href="public/css/yuan.css" rel="stylesheet" type="text/css"/>
    <!--[if lte IE 9]>
    <script type="text/javascript" src="public/js/html5shiv-printshiv-3.js"></script>
    <![endif]-->
</head>
<body>
<div class="bg">
    <?php $this->load->view('common/header.php');?>
    <!--common - head end-->

    <div class="container mt30">
        <div class="my-center-container">
            <?php $this->load->view('member/personal_left.php');?>
            <div class="my-center-right" style="overflow:visible; border: none;background-color: #f9f9f9">
                <div class="my-center-chat-box-wrapper">
                    <div class="chat-box">
                        <div class="chat-box-top">
                            <div class="yuan">
                                <div class="yuan_bl1"></div>
                                <div class="yuan_text">总额度 <br>¥ <em
                                            class="num-all"><?=$admin['account_period_quota']?></em></div>
                                <p class="yuan_ky">
                                    可用额度<br>
                                    <span class="num-box color-red">￥<em class="num-ky"><?=$admin['account_period_quota'] - $admin['account_period_quota_used']?></em></span>
                                </p>
                                <?php if ($unpayorder['bill_bn']): ?>
                                    <p class="yuan_dhk">
                                        待还款金额<br>
                                        <span class="num-box">￥<em class="num-dhk"><?=$unpayorder['moneyTotal'] ? $unpayorder['moneyTotal'] : 0?></em></span>
                                    </p>
                                <?php endif;?>
                            </div>
                        </div>
                        <?php if ($unpayorder['bill_bn']): ?>
                            <p class="chat-box-btm">
                                <span class="tit">最近需还款日期 : <?=$unpayorder['should_repayment_date']?></span>
                                <span class="span02">剩余<?=$unpayorder['day']?>天</span>
                                <?php if ($unpayorder['start_repayment_date'] <= date('Y-m-d')): ?>
                                    <?php if ($unpayorder['status'] == 0): ?>
                                        <a href="<?php echo base_url('pay/index'); ?>?bn=<?php echo $unpayorder['bill_bn'] ?>">立即还款</a>
                                    <?php else: ?>
                                        已还款
                                    <?php endif;?>
                                <?php endif;?>
                            </p>
                        <?php endif;?>
                    </div>
                    <div class="chat-cont">
                        <p class="p-tit p-tit-dot">
                            账期：<em>月结</em>
                        </p>
                        <p class="p-tit">
                            额度：<em><?=$admin['account_period_quota']?></em>
                        </p>
                        <p class="p-tit p-tit-dot">
                            账期还款
                        </p>
                        <p class="p-intro ">
                            未还订单金额：￥<?=$unpayorder['moneyTotal'] ? $unpayorder['moneyTotal'] : 0?>
                        </p>
                        <p class="p-intro ">
                            未还订单笔数：<?=$unpayorder['count']?>
                        </p>
                        <p class="p-tit p-tit-dot">
                            账期采购：（截至当前使用账期支付）：
                        </p>
                        <p class="p-intro ">
                            累计采购金额：￥<?=$order['moneyTotal'] ? $order['moneyTotal'] : 0?>
                        </p>
                        <p class="p-intro ">
                            累计采购次数：<?=$order['count']?>
                        </p>
                    </div>
                </div>

                <div class="my-center-right-cont" style="padding: 0;">
                    <div class="corporate-invoice-table-box w100 bg-fff border-box">
                        <table border="1" class="corporate-invoice-tab">
                            <thead>
                            <tr>
                                <th width="120">账单</th>
                                <th width="180">账单周期</th>
                                <th>账单日</th>
                                <th>最后还款日期</th>
                                <th width="60">订单笔数</th>
                                <th>账单总额</th>
                                <th width="60">账单状态</th>
                                <th>账单</th>
                                <th width="180">
                                    <span class="month-prev pre">上月</span>
                                    <div class="month-now">
                                        <input type="text" name="date" id="date" lay-verify="date" value="<?=isset($_GET['date']) ? $_GET['date'] : date('Y-m-d', time())?>" placeholder="选择日期" autocomplete="off" class="layui-input">
                                    </div>
                                    <span class="month-next next">下月</span>
                                </th>
                            </tr>
                            </thead>
                            <tbody>
                            <?php foreach ($result as $itrm): ?>
                                <tr>
                                    <td><?=$itrm['bill_bn']?></td>
                                    <td class="td01"><?=str_replace('-', '/', $itrm['bill_date_from'])?>~<?=str_replace('-', '/', $itrm['bill_date_to'])?></td>
                                    <td><a href="javascript:;"><?=str_replace('-', '/', $itrm['bill_date'])?></a></td>
                                    <td><?=str_replace('-', '/', $itrm['should_repayment_date'])?></td>
                                    <td><?=$itrm['count']?></td>
                                    <td><?=$itrm['zq_money']?> </td>
                                    <?php if ($itrm['st'] === "0"): ?>
                                        <td>待还款</td>
                                    <?php else: ?>
                                        <td>已还款</td>
                                    <?php endif;?>
                                    <td class="td02">
                                        <a href="<?php echo base_url('bill/bill_index'); ?>?bill_id=<?php echo $itrm['bill_id'] ?>">查看</a>
                                    </td>
                                    <td>
                                        <?php if ($itrm['st'] === "0" && $itrm['start_repayment_date'] <= date('Y-m-d')): ?>
                                            <a href="<?php echo base_url('pay/index'); ?>?bn=<?php echo $itrm['bill_bn'] ?>"
                                               class="btn-chat-box-btm">立即还款</a>
                                        <?php elseif ($itrm['st'] === "0" && $itrm['start_repayment_date'] > date('Y-m-d')): ?>
                                            开始还款日: <?=$itrm['start_repayment_date']?>
                                        <?php else: ?>
                                            <?php if ($itrm['zq_money'] == 0): ?>
                                                已自动还款<br>
                                            <?php else: ?>
                                                实际还款日：<?=date("Y/m/d", strtotime($itrm['actual_repayment_date']))?>
                                                <br>
                                            <?php endif;?>
                                            <!--                                            <p class="payment_end">-->
                                            <!--                                                --><?php //if ($itrm['zq_money'] == 0): ?>
                                            <!--                                                    已自动还款<br>-->
                                            <!--                                                --><?php //else: ?>
                                            <!--                                                    实际还款日：--><?//= date("Y/m/d", strtotime($itrm['actual_repayment_date'])) ?>
                                            <!--                                                    <br>-->
                                            <!--                                                --><?php //endif; ?>
                                            <!--                                                恢 复 额 度：￥--><?//= $itrm['zq_money'] ?>
                                            <!--                                            </p>-->
                                        <?php endif;?>
                                    </td>
                                </tr>
                            <?php endforeach;?>
                            </tbody>
                        </table>
                        <!--<table class="layui-hide" id="test"></table>-->
                    </div>
                    <div class="corporate-invoice-table-box mt15 w100 bg-fff border-box">
                        <table border="1" class="corporate-invoice-tab">
                            <thead>
                            <tr>
                                <th width="60">序号</th>
                                <th width="200">发票抬头</th>
                                <th width="120">下单账号</th>
                                <th>联系人</th>
                                <th width="110">联系方式</th>
                                <th>订单金额</th>
                                <th width="130">支付时间</th>
                                <th width="100">订单详情</th>
                                <th width="100">订单状态</th>
                            </tr>
                            </thead>
                            <tbody>
                            <?php foreach ($order['list'] as $k => $item): ?>
                                <tr>
                                    <td><?=$k + 1?></td>
                                    <td class="td01"><?=json_decode($item['invoice'], true)['invoice_company_name']?></td>
                                    <td><a href="javascript:;" title="<?=$item['user_name']?>"><?=$item['user_name']?></a></td>
                                    <td><?=$item['u_name']?></td>
                                    <td><?=$item['user_tel']?></td>
                                    <td><?=$item['order_money']?></td>
                                    <td><?=str_replace('-', '/', date("Y-m-d H:i", strtotime($item['order_payment_at'])))?></td>
                                    <td class="td02">
                                        <a href="<?php echo base_url() ?>order/common?id=<?=$item['order_id']?>">订单详情</a>
                                    </td>
                                    <?php if ($item['order_status'] == 0): ?>
                                        <td>交易关闭</td>
                                    <?php elseif ($item['order_status'] == 1): ?>
                                        <td>交易成功</td>
                                    <?php elseif ($item['order_status'] == 2): ?>
                                        <td>买家已付款</td>
                                    <?php elseif ($item['order_status'] == 3): ?>
                                        <td>卖家已发货</td>
                                    <?php elseif ($item['order_status'] == 4): ?>
                                        <td>等待买家付款</td>
                                    <?php elseif ($item['order_status'] == 5): ?>
                                        <td>交易结束</td>
                                    <?php elseif ($item['order_status'] == 6): ?>
                                        <td>退货中</td>
                                    <?php elseif ($item['order_status'] == 7): ?>
                                        <td>已退货</td>
                                    <?php endif;?>
                                </tr>
                            <?php endforeach;?>
                            </tbody>
                        </table>
                        <!--<table class="layui-hide" id="test"></table>-->
                        <div class="corporate-invoice-page-box">
                            <?php if ($total_page > 1): ?>
                                <?php if ($nowPage > 1): ?>
                                    <a href="<?=$preurl?>" class="page-prev">上一页</a>
                                <?php endif;?>
                                <?php if ($nowPage != $total_page): ?>
                                    <a href="<?=$nexturl?>" class="page-next">下一页</a>
                                <?php endif;?>
                            <?php endif;?>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

<?php $this->load->view('common/bottom.php');?>
<div class="mask none"></div>
<div class="pop corporate-invoice-img-pop none">
    <a href="javascript:;" class="close"></a>
    <img class="corporate-invoice-img" src="" alt="">
</div>
<script type="text/javascript" src="public/js/jquery.min.js"></script>
<script src="public/js/layui/layui.js"></script>
<script type="text/javascript" src="public/js/index.js"></script>
<script type="text/javascript" src="public/js/owl.carousel.min.js"></script>
<script>
    $(function () {
        //初始化
        var bl = parseInt($('.num-ky').html());
        var num_all = $('.num-all').html();

        function delcommafy(num) {//去除千分位中的‘，’
            num = num.replace(/,/gi, '');
            return num;
        }

        var all = delcommafy(num_all);
        var bl_all = parseInt(all);
        bl = (bl / bl_all) * 360;
        var rotatenum = bl;
        if (bl > 180) {
            var blhtml = '';
            rotatenum = bl - 180;
            blhtml += '<div class="yuan_bl2">';
            blhtml += '<div class="yuan_bl4" style="-webkit-transform:rotate(' + rotatenum + 'deg);transform:rotate(' + rotatenum + 'deg);"></div>';
            blhtml += '</div>';
            //$('.yuan_bl1').remove($('.yuan_bl3'));
            $('.yuan_bl1').after(blhtml);
        } else {
            var blhtml = '';
            blhtml += '<div class="yuan_bl3" style="-webkit-transform:rotate(' + rotatenum + 'deg);transform:rotate(' + rotatenum + 'deg);"></div>';
            $('.yuan_bl1').append(blhtml);
        }
    })

    //获取下个月时间
    $(".next").click(function () {
        var start = $('#date').val();
        $('#date').val(getNextMonth(start));
        //var p = "<?=$nowPage?>";
        location.href = '<?php echo base_url(); ?>member/bill_month?date=' + getNextMonth(start)
        // $('#end_time').datebox('setValue', getNextMonth(getNextMonth(start)));
    });

    function getNextMonth(date) {
        var arr = date.split('-');
        var year = arr[0]; //获取当前日期的年份
        var month = arr[1]; //获取当前日期的月份
        var day = arr[2]; //获取当前日期的日
        var days = new Date(year, month, 0);
        days = days.getDate(); //获取当前日期中的月的天数
        var year2 = year;
        var month2 = parseInt(month) + 1;
        if (month2 == 13) {
            year2 = parseInt(year2) + 1;
            month2 = 1;
        }
        var day2 = day;
        var days2 = new Date(year2, month2, 0);
        days2 = days2.getDate();
        if (day2 > days2) {
            day2 = days2;
        }
        if (month2 < 10) {
            month2 = '0' + month2;
        }
        var t2 = year2 + '-' + month2 + '-' + day2;
        return t2;
    }

    //获取上个月

    $(".pre").click(function () {
        var start = $('#date').val();
        $('#date').val(getPreMonth(start));
        //var p = "<?=$nowPage?>";
        location.href = '<?php echo base_url(); ?>member/bill_month?date=' + getPreMonth(start)
    });

    function getPreMonth(date) {
        var arr = date.split('-');
        var year = arr[0]; //获取当前日期的年份
        var month = arr[1]; //获取当前日期的月份
        var day = arr[2]; //获取当前日期的日
        var days = new Date(year, month, 0);
        days = days.getDate(); //获取当前日期中月的天数
        var year2 = year;
        var month2 = parseInt(month) - 1;
        if (month2 == 0) {
            year2 = parseInt(year2) - 1;
            month2 = 12;
        }
        var day2 = day;
        var days2 = new Date(year2, month2, 0);
        days2 = days2.getDate();
        if (day2 > days2) {
            day2 = days2;
        }
        if (month2 < 10) {
            month2 = '0' + month2;
        }
        var t2 = year2 + '-' + month2 + '-' + day2;
        return t2;
    }
</script>
<script>
    layui.use(['element', 'form', 'layedit', 'laydate', 'upload'], function () {
        var element = layui.element; //导航的hover效果、二级菜单等功能，需要依赖element模块
        var form = layui.form
            , layer = layui.layer
            , layedit = layui.layedit
            , laydate = layui.laydate;
        var $ = layui.jquery
            , upload = layui.upload;

        //监听导航点击
        element.on('nav(demo)', function (elem) {
            //console.log(elem)
//      layer.msg(elem.text());
        });
        //日期
        laydate.render({
            elem: '#date-star'
        });
        laydate.render({
            elem: '#date-end'
        });
        laydate.render({
            elem: '#date'
        });
        //监听提交
        form.on('submit(demo1)', function (data) {
            layer.alert(JSON.stringify(data.field), {
                title: '最终的提交信息'
            });
            return false;
        });


    });
</script>
<script type="text/javascript">
    $(function () {

        $(".deal-detail").click(function () {
            $(this).parent().find(".show-more").toggle();
        });
        $(".invoice-detail").click(function () {
            var url = $(this).attr('data-url');
            if (url) {
                $('.corporate-invoice-img').attr("src", url);
                $('.mask,.corporate-invoice-img-pop').show();
            } else {
                layer.msg('暂无发票详情')
            }
        });
//
//    $(".show-more").mouseleave(function(){
//      $(this).parent().find(".show-more").hide();
//    });
    });
</script>
</body>
</html>